package com.demo.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.demo.bean.Demo;
import com.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by lcs on 2018/9/27.
 */
@RestController
public class DemoController {
	@Reference
	private DemoService demoService;
	@RequestMapping("add/{name}")
	public Object add(@PathVariable("name")String name){
		return this.demoService.add(Demo.builder().createTime(new Date()).name(name).build());
	}

	@RequestMapping("get/{page}/{pageSize}")
	public Object get(@PathVariable("page") int page,@PathVariable("pageSize") int pageSize){
		return this.demoService.getPage(page,pageSize);
	}
}
